#! /bin/bash

# This script is expecting an input of machine name, optionally followed by a
# colon and a list of one or more parameters separated by commas between
# brackets.  For example, the following are acceptable:
# qemu-x86
# qemu-cortex-m3: [testimage]
# qemu-cortex-a53: [zephyr-toolchain, testimage]
#
# Turn this list into a series of yml files separated by colons to pass to kas

set -e -u

FILES="ci/$(echo $1 | cut -d ':' -f 1).yml"

for i in $(echo $1 | cut -s -d ':' -f 2 | sed 's/[][,]//g'); do
	# Given that there is no yml file for default, we can simply ignore those
	# parameters.  They are necessary to pass in so that matrix can correctly
	# setup all of the permutations of each individual run.
	if [[ $i == 'default' ]]; then
		continue
	fi
	FILES+=":ci/$i.yml"
done

echo $FILES
